# -*- coding: utf-8 -*-
from utils.utils import *
from utils.config import http_config
import datetime
import json
import requests
import time

null = None
false = False
true = True



def redis_step1():
	# 上报员上报
	print("当前流程:上报员上报信息")
	now = datetime.datetime.now()
	now_time = now.strftime("%m-%d %H:%M:%S")
	token = get_token("06181111111")
	url = "redis_utils/save_sheet_info_redis"
	payload = {"key":"reporter","value_json":{"list":"[{\"hospital\":\"西安交通大学第一附属医院\",\"province\":\"[\\\"陕西省\\\",\\\"西安市\\\",\\\"新城区\\\"]\",\"department\":\"ICU\",\"departmentOther\":null,\"name\":\"124测试\",\"sex\":\"男\",\"disease\":\"12测试\",\"blood\":\"A（RH阴）\",\"location\":\"\",\"case_redis_code\":\"2025-01-24 08:56:56\",\"key\":0}]"}}
	res = opo_post(url,payload,token)
	if(res['code']==200):
		print("保存成功")

def save_step24():
	# 获取医师信息补充
	print("当前流程:获取医师信息补充")
	token = get_token("15002954689")
	url = '/redis_utils/save_sheet_info_redis'
	payload = {"key":"1634_14","value_json":{"medicalRecord":{"name":"01-13 23:15:38","gender":"男","age":"12","birth":"1989-01-01","ethnicOption":"回族","nativePlace":["陕西省","西安市","长安区"],"nationality":"中国","marriage":"未婚","career":"无","postalCode":"655411","choseIdenType":"身份证号","identityCard":"123","workUnit":"123456","hospitalization":"否","spHosp":"","vaccination":"否","relationP":["父"],"relationC":["夫"],"sun":"111","daughter":"","brother":"","sister":"","contact":"123","contactRela":"123","contactPhone":"123","contactAddr":"123","dateToHos":"2025-01-21T08:20:23.847Z","dateToOffice":"2025-01-21T08:20:25.846Z","dateToWrite":"2025-01-22T08:20:27.230Z","primaryDisease":"123","primaryDiseaseDate":"2025-01-21T08:20:30.895Z","coma":"深昏迷","breath":"有","breathMachine":"是","reflex":"有","hypertension":"无","hypertensionYear":"","cardiopathy":"无","cardiopathyYear":"","diabetes":"无","diabetesYear":"","Cerebrovascular":"无","CerebrovascularDiag":"","CerebrovascularYear":"","tumour":"无","liverFailure":"无","kidneyFailure":"无","smokingHis":"无","drinkingHis":"无","operationHis":"无","operation":"","CPRhis":"无","CPRnum":"","CPRtime":"","IDHhis":"无","IDH100":"","IDH80":"","IDH50":"","urineH":"123","urine24H":"123","others":"无","otherDisease":"","valueT":"123","valueP":"123","valueR":"123","valueR1":"123","valueR2":"123","valueBp":"123","height":"123","weight":"123","valueBMI":"123","KidneyFuncDate":"2025-01-02T08:20:53.353Z","KidneyFuncSCr":"123","KidneyFuncBUN":"123","KidneyFuncUa":"123","liverFuncDate":"2025-01-15T08:20:55.622Z","liverFuncAST":"123","liverFuncALT":"123","liverFuncTBIL":"123","liverFuncDBIL":"123","liverFuncALB":"123","electrolyteDate":"2025-01-21T08:30:50.755Z","electrolyteNa":"123","electrolyteK":"123","electrolyteCl":"123","electrolyteCO":"123","DicDate":"2025-01-21T08:30:56.474Z","DicPT":"123","DicAPTT":"123","DicFIB":"123","DicDD":"123","CbcDate":"2025-01-21T08:30:58.128Z","CbcHb":"123","CbcWBC":"123","CbcPLT":"123","CbcCRP":"123","UaDate":"2025-01-21T08:31:01.705Z","UaWBC":"123","UaRBC":"123","UaPro":"123","infectiousDate":"2025-01-21T08:31:03.386Z","infectiousHBV":"阴性","infectiousHCV":"阴性","infectiousHIV":"阴性","infectiousPRP":"阴性","AboDate":"2025-01-21T08:31:05.469Z","Abo":"123","AboRhD":"阴性","microbeDate":"2025-01-21T08:31:06.616Z","microbe":"123","imagingDate":"2025-01-21T08:31:08.414Z","imagingLiver":"123","imagingkidney":"123","imagingHeart":"123","imagingLung":"123"},"deathRecord":{"donateType":"DBCD","brainDeath":{"place":"123","clinicalBrainDeath":{"date":"2025-01-21T08:31:14.180Z","time":"2025-01-21T11:34:12.000Z","doctorFirst":"123","doctorSecond":"123","result":"符合"},"checkItems":{"eegCheck":true,"evoCheck":true,"craCheck":true},"eegExamination":{"date":"2025-01-21T08:31:22.541Z","time":"2025-01-21T08:35:12.000Z","result":"符合"},"evokedPotentialExamination":{"date":"2025-01-07T08:31:26.362Z","time":"2025-01-21T08:35:12.000Z","result":"符合"},"cranialDopplerUltrasound":{"date":"2025-01-21T08:31:30.393Z","time":"2025-01-21T08:35:12.000Z","result":"符合"},"spontaneousRespirationStimulationTest":{"date":"2025-01-21T08:31:32.723Z","time":"2025-01-21T08:34:12.000Z","doctorFirst":"123","doctorSecond":"123","result":"符合"}},"heartDeath":{"date":"2025-01-21T08:31:37.598Z","time":"2025-01-21T08:35:12.000Z","hospital":"123","heartStopMinute":"123","unrecoveredMinute":"123","deathTime":"2025-01-21T08:33:12.000Z"}},"donateRecord":{"livingWill":true,"relativesWill":true,"brainDeath":true,"heartDeath":true,"agreeState":"123","hospital":"123","operation":"123","operatorDoctor":"123","organType":[true,true,true,true,true,true,true,true,true],"other":"1111","operaBeginTime":"2025-01-15T08:06:29.915Z","perfusionTime":"2025-01-22T08:06:25.309Z","operaEndTime":"2025-01-21T08:06:21.317Z"},"hotBloodTime":"1231","bianyuanOrgan":["肾脏","肝脏","心脏","肺脏","角膜","胰腺","小肠","2222","测试新增大器官","测试逻辑删除大器官","11111"],"bianyuanOrganId":["1","2","3","4","5","6","7","25","26","27","28"]}}

	res = opo_post(url,payload,token)

def save_step13():
	print("当前流程:获取医师手术结束")
	token = get_token("15002954689")
	payload = {"key":"1634_8","value_json":{"case_id":"1634","finish":"已完成","obtain_add":"123","obtain_man":"312","obtain_nurse":null,"json":"{\"liver\":{\"texture\":\"质软\",\"save\":\"冷保存\",\"pressure\":\"\",\"flow\":\"\",\"resistance\":\"\",\"estimate\":\"正常\",\"abnormal\":\"\",\"allocation\":\"西安交大一附院\",\"other\":\"\"},\"kidney1\":{\"texture\":\"硬\",\"textureDegree\":\"轻度\",\"save\":\"冷保存\",\"pressure\":\"\",\"flow\":\"\",\"resistance\":\"\",\"length\":\"12\",\"artery\":\"12\",\"vein\":\"12\",\"ureter\":\"单支\",\"estimate\":\"正常\",\"biopsy\":\"否\",\"biopsyResult\":\"\",\"abnormal\":\"\",\"allocation\":\"西安交大一附院\",\"other\":\"\"},\"kidney2\":{\"texture\":\"硬\",\"textureDegree\":\"轻度\",\"save\":\"冷保存\",\"pressure\":\"\",\"flow\":\"\",\"resistance\":\"\",\"length\":\"12\",\"artery\":\"12\",\"vein\":\"12\",\"ureter\":\"单支\",\"estimate\":\"正常\",\"biopsy\":\"否\",\"biopsyResult\":\"\",\"abnormal\":\"\",\"allocation\":\"西安交大一附院\",\"other\":\"\"},\"heart\":{\"save\":\"冷保存\",\"pressure\":\"\",\"flow\":\"\",\"resistance\":\"\",\"estimate\":\"正常\",\"abnormal\":\"\",\"biopsy\":\"否\",\"biopsyResult\":\"\",\"allocation\":\"西安交大一附院\",\"other\":\"\"}}","check_organ_num":"3","little_organ_id_list":["1","5","7"],"obtain_nurse_id":"126","checkOrgans":{"肾脏":true,"肝脏":true,"心脏":true},"organsOptions":["肾脏","肝脏","心脏"],"notGainReason":{}}}
	res = opo_post(url,payload,token)



def save_step23():
	# 获取结束后完善表
	token = get_token('06182222222')
	print("当前流程:协调员-获取结束后完善表")
	url = "/coordinator_form_utils/insert_coordinator_supplement_sheet"
	payload = {"key":"1634_4","value_json":{"hosNumber":"123","determineDoctor1":"131","determineDoctor2":"133","deathDate":"2025-01-24","deathTime":"2025-01-24T02:41:20.000Z","beginDate":"2025-01-24","beginTime":"2025-01-24T02:41:20.000Z","endDate":"2025-01-31","endTime":"2025-01-24T02:41:20.000Z","relationName":"123","relationPhone":"1234567890","nowAddress":"1231","goType":"移交亲属","mianhuai":"是","huifu":"是","relation":["配偶"]}}
	res = opo_post(url,payload,token)
	if(res['code'] == 200):
		print("获取结束后完善表填写成功")


def test():
	url = "http://localhost:9090/formTemplates/ethicalReviewForm.docx"
	res = requests.get(url)
	print(res.content)

if __name__ == '__main__':
	# redis_step1()
	# save_step24()
	test()